package com.terrapages.wmsc4j.client.mosaic.prodcon;

import java.awt.Graphics;

import com.lisasoft.patterns.producerconsumer.Consumer;
/**
 * Paints the {@link PlacableImage} into the {@link Graphics} object
 * @author mvivian
 *
 */
public class TileImageConsumer extends Consumer<PlacableImage>{
	private Graphics graphics;
	
	/**
	 * @param queue Cant have a Consumer without somthing to consume
	 * @param graphics Images get painted onto this
	 */
	public TileImageConsumer(Graphics graphics) {
		this.graphics = graphics;
	}

	@Override
	/**
	 * paints image into the Graphics object
	 */
	public void consume(final PlacableImage image) {
		graphics.drawImage(
			image.getImage(),
			image.getPlacement().x,
			image.getPlacement().y,
			null
		);
		image.setImage(null);
	}
}
